package com.wiscamp.ninechapters.problems.infrastructure.po.sets;

import com.wiscamp.ninechapters.ddd.PersistenceObject;
import jakarta.persistence.*;
import lombok.Data;

import java.io.Serial;
import java.time.LocalDateTime;

/**
 * 习题集
 */
@Table(name = "problem_sets_view")
@Entity
@Data
public class ProblemSetView implements PersistenceObject {

    @Serial
    private static final long serialVersionUID = -7892253238915131253L;

    /**
     * 习题集编号
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "set_id", insertable = false, nullable = false)
    private long setId = 0;

    /**
     * 习题集代码
     */
    @Column(name = "set_code", nullable = false)
    private String setCode = "";

    /**
     * 习题集名称
     */
    @Column(name = "set_name", nullable = false)
    private String setName = "";

    /**
     * 习题集类型
     */
    @Column(name = "set_type_id", nullable = false)
    private int setTypeId = 0;

    /**
     * 关联编号
     */
    @Column(name = "reference_id", nullable = false)
    private long referenceId = 0;

    /**
     * 规则编号
     */
    @Column(name = "rule_id", nullable = false)
    private long ruleId = 0;

    /**
     * 机构编号
     */
    @Column(name = "organization_id", nullable = false)
    private long organizationId;

    /**
     * 学科编号
     */
    @Column(name = "subject_id", nullable = false)
    private long subjectId = 0;

    /**
     * 总题数
     */
    @Column(name = "problem_quantity")
    private int problemQuantity = 0;

    /**
     * 题分数
     * 为所有辖题的总分数，每题分数为难度值整除10，最低分数为1
     */
    @Column(name = "total_score", nullable = false)
    private int totalScore = 0;

    /**
     * 答题时限
     * 每题做题时间为5分钟，总题数乘5
     */
    @Column(name = "total_time_limit", nullable = false)
    private int totalTimeLimit = 0;

    /**
     * 是否真题
     */
    @Column(name = "true_problem", nullable = false)
    private boolean trueProblem = false;

    /**
     * 难度系数
     * 所有辖题的平均难度值
     */
    @Column(name = "difficulty", nullable = false)
    private int difficulty = 0;

    /**
     * 备注
     */
    @Column(name = "remark")
    private String remark = "";

    /**
     * 是否可用
     */
    @Column(name = "is_active", nullable = false)
    private boolean enabled = true;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private boolean deleted = false;

    /**
     * 创建用户
     */
    @Column(name = "created_by", nullable = false)
    private long creatorId = 0;

    /**
     * 创建时间
     */
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime creationTime;

    /**
     * 编辑用户
     */
    @Column(name = "modified_by")
    private long modifierId = 0;

    /**
     * 编辑时间
     */
    @Column(name = "modified_time")
    private LocalDateTime modificationTime;

    @Column(name = "collection_name")
    private String collectionName = "";

    @Column(name = "set_type_name")
    private String setTypeName = "";

    @Column(name = "creator_name")
    private String creatorName = "";

    @Column(name = "modifier_name")
    private String modifierName = "";
}
